<include file="public/header" title="找回密码" body=""/>
<include file="public/header_nav" title="找回密码" href="javascript:history.back(-1)"/>
<div class="reset-pwd-steps">
    <img src="__STATIC__/images/pic-reset-psw1.jpg" alt="" />
</div>
<div class="loginsingup-input">
    <form  method="post" id="fpForm">
        <div class="reset-pwd-title">账号验证</div>
        <div class="lsu">
            <span class="ico ico-username"></span>
            <input type="text" name="username" id="username" value="" placeholder="请输入账号"/>
        </div>
        <div class="lsu">
            <span class="ico ico-v-code"></span>
            <input class="v-code-input" type="text" name="verify_code" id="verify_code" value="" placeholder="请输入验证码"/>
            <img class="v-code-pic" src="/index.php?m=Mobile&c=User&a=verify&type=forget" id="verify_code_img" onclick="verify()">
        </div>
    </form>
    <div class="lsu-submit">
        <input type="button" id="btn_submit"  value="下一步" />
    </div>
</div>
</body>
<script>
    //加载验证码
    function verify(){
        $('#verify_code_img').attr('src','/index.php?m=Mobile&c=User&a=verify&type=forget&r='+Math.random());
    }

    var ajax_return_status=1;
    $("#btn_submit").click(function(){
        if (ajax_return_status==0){
            return false;
        }
        ajax_return_status=0;
        var username = $.trim($('#username').val());
        var verify_code = $.trim($('#verify_code').val());
        if(username == ' '){
            ajax_return_status=1;
            showErrorMsg('账号不能为空');
            return false;
        }
       if(verify_code == ''){
           ajax_return_status=1;
           showErrorMsg('验证码不能为空');
           return false;
       }
        $.ajax({
            type: "POST",
            url: '/index.php/mobile/User/forget_pwd',
            data: $("#fpForm").serialize(),
            dataType: 'json',
            success: function (data) {
                ajax_return_status=1;
                if (data.status == 1) {
                    layer.open({content: data.msg, time: 2,end:function(){
                        window.location.href=data.url;
                    }});
                } else {
                    showErrorMsg(data.msg);
                    verify();
                }
            }
        });
    });

</script>
</html>
